package com.hspedu.threaduse;

public class Thread02 {
    public static void main(String[] args) {
        Dog dog = new Dog();

        //创建了一个Thread对象，吧dog对象(实现了Runnable)，放入Thread
        Thread thread = new Thread(dog);
        thread.start();
    }
}

class Dog implements Runnable{//通过实现runnable接口，开发线程

    int count=0;
    @Override
    public void run() {
        while(true){
            System.out.println("小狗汪汪叫 hi..."+(++count)+Thread.currentThread().getName());
            //休眠一秒
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
